package com.gitee.xzb617.mybatis.sqllog.util;

import java.lang.reflect.Modifier;

/**
 * 类型工具
 * @author xuzhibin
 */
public class TypeUtil {

    public static boolean isNormalClass(Class<?> clazz) {
        return null != clazz && !clazz.isInterface() && !isAbstract(clazz) && !clazz.isEnum()
                && !clazz.isArray() && !clazz.isAnnotation() && !clazz.isSynthetic() && !clazz.isPrimitive();
    }

    public static boolean isAbstract(Class<?> clazz) {
        return Modifier.isAbstract(clazz.getModifiers());
    }

    public static boolean isBasicType(Class<?> clazz) {
        return clazz.isAssignableFrom(String.class) || clazz.isAssignableFrom(Number.class) || clazz.isAssignableFrom(Byte.class)
                || clazz.isAssignableFrom(Character.class) || clazz.isAssignableFrom(Boolean.class);
    }

    public static boolean isObjectClass(Class<?> clazz) {
        return isNormalClass(clazz) && !isBasicType(clazz);
    }

}
